import 'package:flutter/material.dart';

class ScreenUtils {
  static final ScreenUtils instance = ScreenUtils._internal();

  factory ScreenUtils() {
    return instance;
  }

  ScreenUtils._internal();

  // 程序初始化传入
  BuildContext? _context;

  void init(BuildContext context) {
    _context = context;
  }

  // 屏幕宽度
  double get screenWidth {
    return MediaQuery.of(_context!).size.width;
  }

  // 屏幕高度
  double get screenHeight {
    return MediaQuery.of(_context!).size.height;
  }

  // 导航栏高度
  double get navigatBarHeight {
    return AppBar().preferredSize.height;
  }

  // 状态栏高度
  double get statusBarHeight {
    return MediaQuery.of(_context!).padding.top;
  }

  // 底部安全区域高度
  double get bottomSafeHeight {
    return MediaQuery.of(_context!).padding.bottom;
  }
}
